home *** CD-ROM | disk | FTP | other *** search
/ Collection of Tools & Utilities / Collection of Tools and Utilities.iso / c / mc51bugs.zip / Q31558 < prev    next >
Text File  |  1988-07-21  |  1KB  |  38 lines

  1. Q31558 Optimizing for Size Causes Incorrect Code Generation
  2. C Compiler
  3. 5.10
  4. MS-DOS
  5.  
  6. Summary:
  7.    You will receive incorrect results when optimizing for size using
  8. the /Os switch in the following example. By generating two different
  9. assembly listings, one with /Ods and the other with /Od, the difference
  10. in the code generated can be seen.
  11.    The workaround for this problem is to compile the offending module
  12. without optimizing for size.
  13.    This is a known problem in Version 5.10 of the C compiler.
  14.    Microsoft is researching this problem and will post new information
  15. as it becomes available.
  16.  
  17. More Information:
  18.    The following code correctly outputs the value 32 as long as size
  19. optimization is not specified. However, when optimizing for size, the
  20. following code incorrectly outputs the value 33:
  21.  
  22. /* The following aligns something on the next word address boundary */
  23. main()
  24. {
  25.     unsigned int  alloc_addr;
  26.  
  27.     alloc_addr = 30;
  28.     alloc_addr += 2;
  29.  
  30.      alloc_addr = (((((alloc_addr) - 1) >> 1) + 1) << 1);
  31.      printf("%u\n",alloc_addr);
  32. }
  33.  
  34.  
  35.  
  36. Keywords:  buglist5.10
  37. Updated  88/07/21 03:19
  38.